// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Create a trench behind player
// -----------------------------------------------

private ["_trench","_mydir","_position","_player"];

_player = _this select 1;

_mydir = getDir _player;
_position = [(getPosATL _player select 0) + ((sin _mydir) * 2), (getPosATL _player select 1) + ((cos _mydir) * 2), (getPosATL _player) select 2];

if (((getPosATL player) distance (getMarkerPos "respawn_west")) < 300) exitWith { 
	wcgarbage = [localize "STR_WC_MESSAGEDIGATRENCH", localize "STR_WC_MESSAGETRYTOMOVEOUT", localize "STR_WC_MESSAGECANDIG", 10] spawn WC_fnc_playerhint;
};

player playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 10;
if !(alive player) exitWith {};

//A3 TODO: Trench
_trench = createVehicle ["Fort_envelopeBig_EP1", _position, [], 0, "NONE"];
_trench setPosATL _position;
_trench setDir _mydir;